package com.gin.kotlin.no_gay_alliance.runner

import android.util.Log
import com.gin.kotlin.no_gay_alliance.app.App
import com.gin.kotlin.no_gay_alliance.app.AppRunner
import com.gin.kotlin.no_gay_alliance.callback.RCallback
import com.gin.kotlin.no_gay_alliance.manager.AccountManager
import com.gin.kotlin.no_gay_alliance.provider.ngaphp.BlockConfigProvider
import com.gin.nga.response.user.BlockConfigBody

/**
 * 初始化账号管理器
 */
class AccountManagerRunner:AppRunner {
    @Suppress("PrivatePropertyName")
    private val TAG = this::class.java.simpleName
    /**
     * 执行的任务内容
     * @param app [App]
     */
    override fun run(app: App) {
        AccountManager.getInstance().init()

        BlockConfigProvider.getInstance().enqueue(callback = object : RCallback<BlockConfigBody, Nothing> {
            override fun onSuccess(data: BlockConfigBody, ignoreCache: Boolean) {
                App.INSTANCE.blockConfig = data.data
            }

            override fun onError(errorMessage: String) {
                Log.w(TAG, "屏蔽数据获取错误: $errorMessage")
            }
        })
    }
}